bits 64

;void jmp_to_new_stack(void *stack_buffer, size_t stack_size, void(*function_to_run)(void *userdata), void *userdata, jmp_buf returning, int longjmp_value);
jmp_to_new_stack:
	mov rax, rsp
	mov rsp, rcx
	add rsp, rdx
	push qword [rax + 48]
	push qword [rax + 40]
	mov rcx, r9
	sub rsp, 32
	call r8
	add rsp, 32
	pop rcx
	pop rdx
	jmp my_longjmp
	times 8 - ($ - $$ & 7) nop

%include "x64_my_longjmp.asm"
